<?php
namespace app\course\validate\coupon;

use think\Validate;

/**
 * 卡券验证
 */
class Coupon extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名'    =>    ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'course_id'      => 'require|number',
        'mhm_id'         => 'require|number',
        'price'          => 'require|float',
        'id'             => 'require|number',
    ];

    protected $field = [
        'course_id' => '课程',
        'mhm_id'    => '机构',
        'id'        => '卡券',
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名'    =>    '错误信息'
     *
     * @var array
     */
    protected $message = [
        'id.require'  => '卡券不能为空',
    ];

    /**
     * 验证场景
     */
    protected $scene = [
        'course'        => ['course_id'],
        'school'        => ['mhm_id'],
        'user_school'   => ['mhm_id', 'price'],
        'exchange'      => ['id'],
    ];

}
